package com.sky.controller.admin;

import com.sky.result.Result;
import com.sky.service.DishService;
import com.sky.service.OrderService;
import com.sky.service.ReportService;
import com.sky.service.SetmealService;
import com.sky.vo.BusinessDataVO;
import com.sky.vo.DishOverViewVO;
import com.sky.vo.OrderOverViewVO;
import com.sky.vo.SetmealOverViewVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@RestController()
@RequestMapping("/admin/workspace")
@Slf4j
@Api(tags = "工作台相关接口")
public class WorkspaceController {

    @Autowired
    ReportService reportService;

    @Autowired
    OrderService orderService;

    @Autowired
    DishService dishService;

    @Autowired
    SetmealService setmealService;

    @GetMapping("/businessData")
    public Result<BusinessDataVO> businessData(){
        log.info("获取今日的营业数据");
        BusinessDataVO businessDataVO = reportService.bussinessData(LocalDate.now(), LocalDate.now());
        return Result.success(businessDataVO);

    }

    /**
     * 获取当日各种订单状态数量
     * @return
     */
    @GetMapping("/overviewOrders")
    @ApiOperation("获取当日各种订单状态数量")
    public Result<OrderOverViewVO> overviewOrders(){
        log.info("获取当日各种订单状态数量");
        OrderOverViewVO orderOverViewVO = orderService.overviewOrders();
        return Result.success(orderOverViewVO);

    }
    /**
     * 获取菜品起售和停售的数量
     * @return
     */
    @GetMapping("/overviewDishes")
    @ApiOperation("获取菜品起售和停售的数量")
    public Result<DishOverViewVO> overviewDishes(){
        log.info("获取菜品起售和停售的数量");
        DishOverViewVO dishOverViewVO= dishService.overviewDishes();
        return Result.success(dishOverViewVO);

    }
    /**
     * 获取套餐起售和停售的数量
     * @return
     */
    @GetMapping("/overviewSetmeals")
    @ApiOperation("获取套餐起售和停售的数量")
    public Result<SetmealOverViewVO> overviewSetmeals(){
        log.info("获取套餐起售和停售的数量");
        SetmealOverViewVO setmealOverViewVO= setmealService.overviewSetmeals();
        return Result.success(setmealOverViewVO);

    }
}
